import request from '@/utils/request'
import type { loginForm, reqRespones } from './type'
// 枚举接口
enum API {
  LOGIN_URL = '/user/login',
  REGISTER_URL = '/user/register',
  FORGET_URL = '/user/forget',
  RESET_PWD_URL = '/user/resetPassword',
  LAYOUT_LOGIN = '/user/logout',
  UPDATE_USER_INFO = '/user/updateInfo',
}

// 登录
export const reqLogin = (data: loginForm) => request.post<any, reqRespones>(API.LOGIN_URL, data)
// 注册
export const reqRegister = (data: loginForm) =>
  request.post<any, reqRespones>(API.REGISTER_URL, data)
// 忘记密码
export const reqForgetPwd = (params: any) =>
  request.get<any, reqRespones>(API.FORGET_URL, { params })
// 重置密码
export const reqResetPwd = (data: any) => request.patch<any, reqRespones>(API.RESET_PWD_URL, data)
// 退出登录
export const reqLogout = () => request.post<any, reqRespones>(API.LAYOUT_LOGIN)
// 更新用户信息
export const reqUpdateUserInfo = (data: any) =>
  request.put<any, reqRespones>(API.UPDATE_USER_INFO, data)

// export function authCodeLogin(params) {
//     return request({
//         url: baseUrl + "/authCodeLogin/" + params.code,
//         method: "get",
//     });
// }
